package com.skivingcloud.report.service.impl;

import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.skivingcloud.report.entity.ReportFormsDatasourceAttrs;
import com.skivingcloud.report.mapper.ReportFormsDatasourceAttrsMapper;
import com.skivingcloud.report.service.ReportFormsDatasourceAttrsService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.skivingcloud.common.utils.PageParameter;

/**
 * 填报报表单元格与填报数据源属性绑定关系表 服务层实现。
 *
 * @author skivingcloud
 * @since 2024-11-07
 */
@Service
public class ReportFormsDatasourceAttrsServiceImpl extends ServiceImpl<ReportFormsDatasourceAttrsMapper, ReportFormsDatasourceAttrs> implements ReportFormsDatasourceAttrsService {

    /**
     * 分页查询填报报表单元格与填报数据源属性绑定关系表
     *
     * @param parameter 查询参数
     * @return 分页查询结果
     */
    @Override
    public Page<ReportFormsDatasourceAttrs> queryByPage(PageParameter<ReportFormsDatasourceAttrs> parameter){
        Page<ReportFormsDatasourceAttrs> page = new Page<>(parameter.getPage(), parameter.getPageSize());
        QueryWrapper queryWrapper = QueryWrapper.create();
        if (parameter.getParam() != null) {
            //查询条件
            if (StringUtils.isNoneBlank(parameter.getParam().getId())) {
                queryWrapper.and(ReportFormsDatasourceAttrs::getId).like(parameter.getParam().getId());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getReportFormsDatasourceId())) {
                queryWrapper.and(ReportFormsDatasourceAttrs::getReportFormsDatasourceId).like(parameter.getParam().getReportFormsDatasourceId());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getType())) {
                queryWrapper.and(ReportFormsDatasourceAttrs::getType).like(parameter.getParam().getType());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getCellCoords())) {
                queryWrapper.and(ReportFormsDatasourceAttrs::getCellCoords).like(parameter.getParam().getCellCoords());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getColumnName())) {
                queryWrapper.and(ReportFormsDatasourceAttrs::getColumnName).like(parameter.getParam().getColumnName());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getIdType())) {
                queryWrapper.and(ReportFormsDatasourceAttrs::getIdType).like(parameter.getParam().getIdType());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getCreator())) {
                queryWrapper.and(ReportFormsDatasourceAttrs::getCreator).like(parameter.getParam().getCreator());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getUpdater())) {
                queryWrapper.and(ReportFormsDatasourceAttrs::getUpdater).like(parameter.getParam().getUpdater());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getDelFlag())) {
                queryWrapper.and(ReportFormsDatasourceAttrs::getDelFlag).like(parameter.getParam().getDelFlag());
            }
        }
        return this.page(page, queryWrapper);
    }
}
